package com.monitor.controller;


import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.monitor.dao.ErpSheetIdMapper;
import com.monitor.entity.*;
import com.monitor.service.*;
import com.monitor.util.BlankUtil;
import com.monitor.util.IDUtils;
import com.monitor.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 检测维护销售维修工作单表 前端控制器
 * </p>
 *
 * @author LX
 * @since 2018-09-28
 */
@RestController
@RequestMapping("/erpManagement")
@Api(description="工作汇总")
public class ErpManagementController {

    @Resource
    private ErpManagementService managementService;
    @Resource
    private ErpUserService userService;
    @Resource
    private ErpCustomerService customerService;
    @Resource
    private ErpCustomerCarService carService;
    @Resource
    private ErpClaimsService claimsService;
    @Resource
    private ErpSaleRepairGarageService saleRepairGarageService;
    @Resource
    private ErpSaleRepairRepairService saleRepairRepairService;
    @Resource
    private ErpSaleRepairOrderService repairOrderService;
    @Resource
    private ErpSaleRepairSaleService repairSaleService;
    @Resource
    private ErpMaterielFlowMaterielService flowMaterielService;
    @Resource
    private ErpMaterielFlowService flowService;
    @Resource
    private ErpMaterielFlowSummaryService flowSummaryService;
    @Resource
    private ErpTireArchivesService archivesService;
    @Resource
    private ErpTireArchivesWorkService archivesWorkService;
    @Resource
    private ErpInspectionOrderService inspectionOrderService;
    @Resource
    private ErpInspectionContentService inspectionContentService;
    @Resource
    private ErpParametersService parametersService;
    @Resource
    private ErpUserService usersService;
    @Resource
    private ErpCustomerWarehouseService erpCustomerWarehouseService;
    
    @Resource
    private ErpSheetIdMapper erpSheetIdMapper;
    //新增的
    @RequestMapping("/getGuaCar")
    @ApiOperation("查询所有挂车")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> getGuaCar(Integer custId) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String,Object>();
            List<ErpCustomerCar> erpCustomerCars = carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("car_type2", "挂车").eq("customer_id",custId));

            map.put("guache",erpCustomerCars);
            result.setCount(1);
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }    //新增的
    @RequestMapping("/getNoGuaCar")
    @ApiOperation("查询所有不是挂车的车")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> getNoGuaCar(Integer custId) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String,Object>();
            List<ErpCustomerCar> erpCustomerCars = carService.selectList(new EntityWrapper<ErpCustomerCar>().notIn("car_type2", "挂车").eq("customer_id",custId));

            map.put("car",erpCustomerCars);
            result.setCount(erpCustomerCars.size());
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/jianceweihuCarTireArchivesWork")
    @ApiOperation("检测维护添加车辆检测信息-确定按钮")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "carPlate", value = "车牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "登陆的用户id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")*/
    })
    public @ResponseBody
    Result<Integer> jianceweihuCarTireArchivesWork(ErpTireArchivesWork tireArchivesWork) {
        Result<Integer>  result=new Result<Integer>();
        try{
            /////////////////////添加轮胎质量检测档案/////////////////////////////////////
                tireArchivesWork.setWorkDate(new Date());
                archivesWorkService.insert(tireArchivesWork);
            result.setCount(1);
            result.setData(1);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/jianceweihuCarInspectionContent")
    @ApiOperation("检测维护添加车辆检测内容-确定按钮")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "carPlate", value = "车牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "登陆的用户id", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "carPlate", value = "车牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "orderId", value = "车辆检测单id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Integer> jianceweihuCarInspectionContent(Integer orderId,ErpInspectionContent inspectionContent,String carPlate,String guaPlate) {
    	String plate="";
    	if(carPlate!=null&&!carPlate.equals("")) {
    		plate=carPlate;
    	}else {
    		plate=guaPlate;
    	}
        Result<Integer>  result=new Result<Integer>();
        try{
          /*  String unit="";
            ErpCustomerCar car=null;
            car=carService.selectByCarPlate(plate);
            if ( car!=null){
                ErpCustomer cust=customerService.selectById(car.getCustomerId());
                if(cust!=null) {
                	unit=cust.getCusName();
                }
            }
            inspectionContent.setUnit(unit);*/
            inspectionContent.setCustomerId(plate);
            inspectionContent.setPid(orderId);
            Date currentTime = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(currentTime);
            inspectionContent.setDt(dateString);
            inspectionContentService.insert(inspectionContent);
            result.setCount(1);
            result.setData(1);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/gojianceweihuCarDataSure")
    @ApiOperation("检测维护查询车辆维护数据-确定按钮")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "carPlate", value = "车牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "登陆的用户id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> gojianceweihuCarDataSure(String carPlate,String guaPlate,Integer userId,Integer custId,ErpInspectionOrder inspectionOrder/*,List<ErpInspectionContent> inspectionContents,List<ErpTireArchivesWork> tireArchivesWorkss*/) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String, Object>();
            /*List<ErpTireArchivesWork> tireArchivesWorks=archivesWorkService.selectList(new EntityWrapper<ErpTireArchivesWork>().eq("work_sheet_id",inspectionOrder.getFormId()));*/
            /////////////////////添加轮胎质量检测档案/////////////////////////////////////
            /*for (ErpTireArchivesWork tireArchivesWork:tireArchivesWorkss) {
                tireArchivesWork.setWorkDate(new Date());
                archivesWorkService.insert(tireArchivesWork);
            }*/
            /////////////////////添加工作单/////////////////////////////////////
            String unit="";
            ErpCustomerCar car=null;
            if(carPlate!=null&&!carPlate.equals("")) {
            	car=carService.selectByCarPlate(carPlate);
            }else {
            	car=carService.selectByCarPlate(guaPlate);
            }
            if ( car!=null){
                ErpCustomer cust=customerService.selectById(car.getCustomerId());
                if(cust!=null) {
                	unit=cust.getCusName();
                }
            }
           ErpManagement management = new ErpManagement();
            management.setWorkPlace(customerService.selectById(custId).getCusName());
            Date currentTime = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMdd");
            String date=formatter1.format(currentTime);
            String dateString = formatter.format(currentTime);
            management.setDt(dateString);
            String id="JCWH"+date;
            List<ErpInspectionOrder> erpInspectionOrders = inspectionOrderService.selectList(new EntityWrapper<ErpInspectionOrder>().like("form_id", id).orderBy("id", false));
            if(erpInspectionOrders!=null&&erpInspectionOrders.size()>0) {
	            ErpInspectionOrder emfs = erpInspectionOrders.get(0);
	            String sheelId=emfs.getFormId().substring(12,emfs.getFormId().length());
	            sheelId=IDUtils.addOne(sheelId);
	            id=id+sheelId;
            }else {
            	id+="00001";
            }
            management.setWorkId(id);
            management.setClientName(unit);
            management.setCarNumber(carPlate);
            management.setWorkProject("维护/检测");
            management.setPurchase(0.0);
            management.setSail(0.0);
            management.setErpRepair(0.0);
            management.setMaintian(inspectionOrder.getActualFee());
            management.setCope(0.0);
            if(inspectionOrder.getPaidMethod().equals("应收账款")){
                management.setAccounts(inspectionOrder.getActualFee());
                management.setCash(0.0);
            }else if(inspectionOrder.getPaidMethod().equals("免费")){
                management.setAccounts(0.0);
                management.setCash(0.0);
                management.setMaintian(0.0);
            }else{
                management.setAccounts(0.0);
                management.setCash(inspectionOrder.getActualFee());
            }
            management.setWorkAttn(usersService.selectById(userId).getRealName());
            management.setClientAttn(inspectionOrder.getCustomer());
            managementService.insert(management);
            inspectionOrder.setFormId(id);
            inspectionOrderService.insert(inspectionOrder);
//            List<ErpInspectionContent> customer_id = inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("customer_id", carPlate));
//       if (customer_id!=null){
//           for (int i = 0; i < customer_id.size(); i++) {
//               ErpInspectionContent erpInspectionContent =  customer_id.get(i);
//               if (erpInspectionContent.getFormId()==null||erpInspectionContent.getFormId().equals("2")){
//                   erpInspectionContent.setFormId(id);
//                   inspectionContentService.updateById(erpInspectionContent);
//               }
//           }
//       }


            map.put("management",management);
            map.put("inspectionOrder",inspectionOrder);
           /* for (ErpInspectionContent inspectionContent:inspectionContents) {
                inspectionContent.setUnit(unit);
                inspectionContent.setPid(inspectionOrder.getId());
                inspectionContentService.insert(inspectionContent);
            }*/
            ErpSheetId sheet=new ErpSheetId();
            sheet.setSheetDate(new Date());
            sheet.setSheetType("JCWH");
            sheet.setSheetId(management.getWorkId());
            sheet.setSheetSort(1);
            sheet.setSheetComplete(1);
            erpSheetIdMapper.insert(sheet);
            //需要添加erp_tire_archives_work表
            result.setCount(1);
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    //去重
    private static ArrayList<ErpInspectionContent> removeDuplicateUser(List<ErpInspectionContent> users) {
        Set<ErpInspectionContent> set = new TreeSet<ErpInspectionContent>(new Comparator<ErpInspectionContent>() {
            @Override
            public int compare(ErpInspectionContent o1, ErpInspectionContent o2) {
                //字符串,则按照asicc码升序排列
                return o1.getTirePlace().compareTo(o2.getTirePlace());
            }
        });
        set.addAll(users);
        return new ArrayList<ErpInspectionContent>(set);
    }

    @RequestMapping("/gojianceweihuCarData")
    @ApiOperation("检测维护查询车辆维护数据") //11111
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "catPlate", value = "车牌号", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> gojianceweihuCarData(String catPlate) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String, Object>();
            Integer contentId=inspectionContentService.getMaxIdContent(catPlate);
            if(null==contentId || 0==contentId){
                result.setCount(0);
                result.setData(null);
                return result;
            }
            ErpInspectionContent content=inspectionContentService.selectById(contentId);

            List<ErpInspectionOrder> inspectionOrder=inspectionOrderService.selectList(new EntityWrapper<ErpInspectionOrder>().eq("form_id",content.getFormId()));   //报空了,null了NullPointerException
            List<ErpTireArchivesWork> archives=archivesWorkService.selectList(new EntityWrapper<ErpTireArchivesWork>().eq("work_sheet_id",content.getFormId()));

            List<ErpInspectionContent> contents=new ArrayList<ErpInspectionContent>();
            List<ErpInspectionContent> contents2=new ArrayList<ErpInspectionContent>();
            contents=inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("form_id",content.getFormId()).and().eq("customer_id",catPlate));
            if(0==contents.size()){
                contents=inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("customer_id",catPlate));
            }
            for(ErpInspectionContent content1:contents){
                ErpParameters parameters=parametersService.selectOne(new EntityWrapper<ErpParameters>().eq("norms",content1.getSpecification()).and().eq("model",content1.getSize()).and().eq("arand",content1.getBrand()).and().eq("address",content1.getProducePlace()));
                if(null==parameters){
                    continue;
                }
                content1.setDeepLines1(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
                content1.setDeepLines2(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
                content1.setDeepLines3(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
                content1.setDeepLines4(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
                contents2.add(content1);
            }
            map.put("archives",archives);
            map.put("inspectionOrder",inspectionOrder);
            List<ErpInspectionContent> arrayList=new ArrayList<ErpInspectionContent>();
//          SortList<String> sortList=new SortList<String>().getSortList(contents2,"dt");
//            contents2.parallelStream().forEach((ErpInspectionContent con) ->{
//
//            });


            ArrayList<ErpInspectionContent> erpInspectionContents = removeDuplicateUser(contents2);
            map.put("contents",erpInspectionContents);
            if (null!=inspectionOrder){
                map.put("inspectionOrder",inspectionOrder);
            }
            result.setCount(1);
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

@RequestMapping("/gojianceweihuByOrder")
    @ApiOperation("检测维护单号查询检测维护")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "order", value = "订单号", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> gojianceweihuByOrder(String order) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String, Object>();
//            List<ErpInspectionContent> pid = new ArrayList<>();
//            if (form_id != null) {
//             pid = inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("pid", form_id.getId()));
//            }
//            List<ErpTireArchivesWork> list =new ArrayList<>();
//            if (pid!=null){
//
//            for (int i = 0; i < pid.size(); i++) {
//                ErpInspectionContent erpInspectionContent =  pid.get(i);
//                ErpTireArchivesWork tire_id = archivesWorkService.selectOne(new EntityWrapper<ErpTireArchivesWork>().eq("tire_id", erpInspectionContent.getTireId()));
//                list.add(tire_id);
//            }            }
//
//            map.put("inspectionOrder",form_id);
//            map.put("archives",list);
//            map.put("contents",pid);



            //2
//                        ErpInspectionContent form_id = inspectionContentService.selectOne(new EntityWrapper<ErpInspectionContent>().eq("form_id", order));
//            Integer contentId=form_id.getId();
//            if(null==contentId || 0==contentId){
//                result.setCount(0);
//                result.setData(null);
//                return result;
//            }
//            ErpInspectionContent content=inspectionContentService.selectById(contentId);
//
//            List<ErpInspectionOrder> inspectionOrder=inspectionOrderService.selectList(new EntityWrapper<ErpInspectionOrder>().eq("form_id",content.getFormId()));   //报空了,null了NullPointerException
//            List<ErpTireArchivesWork> archives=archivesWorkService.selectList(new EntityWrapper<ErpTireArchivesWork>().eq("work_sheet_id",content.getFormId()));
//
//            List<ErpInspectionContent> contents=new ArrayList<ErpInspectionContent>();
//            List<ErpInspectionContent> contents2=new ArrayList<ErpInspectionContent>();
//            contents=inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("pid",content.getFormId()));
//
//            for(ErpInspectionContent content1:contents){
//                ErpParameters parameters=parametersService.selectOne(new EntityWrapper<ErpParameters>().eq("norms",content1.getSpecification()).and().eq("model",content1.getSize()).and().eq("arand",content1.getBrand()).and().eq("address",content1.getProducePlace()));
//                if(null==parameters){
//                    continue;
//                }
//                content1.setDeepLines1(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
//                content1.setDeepLines2(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
//                content1.setDeepLines3(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
//                content1.setDeepLines4(StringUtils.isEmpty(parameters.getLinesS())?0.0:Double.parseDouble(parameters.getLinesS()));
//                contents2.add(content1);
//            }
//            map.put("archives",archives);
//            map.put("inspectionOrder",inspectionOrder);
//            List<ErpInspectionContent> arrayList=new ArrayList<ErpInspectionContent>();
////          SortList<String> sortList=new SortList<String>().getSortList(contents2,"dt");
////            contents2.parallelStream().forEach((ErpInspectionContent con) ->{
////
////            });
//
//
//            ArrayList<ErpInspectionContent> erpInspectionContents = removeDuplicateUser(contents2);
//            map.put("contents",erpInspectionContents);
//            if (null!=inspectionOrder){
//                map.put("inspectionOrder",inspectionOrder);
//            }


            ErpInspectionOrder form_id = inspectionOrderService.selectOne(new EntityWrapper<ErpInspectionOrder>().eq("form_id", order));
            List<ErpInspectionContent> pid = inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("pid", form_id.getId()));
            List<ErpInspectionOrder> orderList=inspectionOrderService.selectList(new EntityWrapper<ErpInspectionOrder>().le("id", form_id.getId()).and().ne("id", form_id.getId()).orderBy("id", false));
            List<ErpInspectionContent> oldContent=new ArrayList<>();
            if(orderList!=null&&orderList.size()>0&&pid!=null&&pid.size()>0) {
            	for(ErpInspectionOrder old:orderList) {
            		oldContent=inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("pid", old.getId()));
            		if(oldContent!=null&&oldContent.size()>0) {
            			ErpInspectionContent content=oldContent.get(0);
            			if(content.getCustomerId().equals(pid.get(0).getCustomerId())) {
            				break;
            			}
            		}
	            	
            	}
            }
            map.put("order",form_id);
            map.put("content",pid);
            map.put("oldContent",oldContent);
            result.setCount(1);
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }


    @RequestMapping("/anchetongji")
    @ApiOperation("统计管理-按车统计")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "carPlate", value = "车辆牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<List<Object>> anchetongji(Integer custId,String startDate,String endDate,String carPlate) {
        Result<List<Object>>  result=new Result<List<Object>>();
        try{
            List<Object> objectList=new ArrayList<Object>();
            Double allpurchase=0.0;
            Double allerp_repair=0.0;
            Double allmaintian=0.0;
            Double allmoney=0.0;
            Integer wokeNum=0;
            List<String> carids=new ArrayList<String>();
            if(!StringUtils.isEmpty(carPlate)){
                carids.add(carPlate);
            }else{
                List<ErpCustomerCar> customerCars=carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("customer_id",custId));
                carids=customerCars.stream().distinct().map(ErpCustomerCar::getCarPlate).collect(Collectors.toList());
            }
            List<Map<String,Object>> mapList=new ArrayList<Map<String, Object>>();
            for (int i = 0; i <carids.size() ; i++) {
                /*List<ErpSaleRepairOrder> repairOrders=repairOrderService.selectList(new EntityWrapper<ErpSaleRepairOrder>().ge("sale_repair_date",startDate).and().le("sale_repair_date",endDate).and().eq("car_plate",carids.get(i)).or().ge("sale_repair_date",startDate).and().le("sale_repair_date",endDate).and().eq("trailer_plate",carids.get(i)));*/
                List<ErpManagement> managementList=managementService.selectList(new EntityWrapper<ErpManagement>().eq("car_number",carids.get(i)).and().ge("dt",startDate).and().le("dt",endDate));
                if(0<managementList.size()){
                    wokeNum+=managementList.size();
                    Double purchase=managementList.stream().mapToDouble(ErpManagement::getPurchase).sum();
                    Double erp_repair=managementList.stream().mapToDouble(ErpManagement::getErpRepair).sum();
                    Double maintian=managementList.stream().mapToDouble(ErpManagement::getMaintian).sum();
                    allpurchase+=purchase;allerp_repair+=erp_repair;allmaintian+=maintian;
                    allmoney+=purchase+erp_repair+maintian;
                    Map<String,Object> map=new HashMap<String, Object>();
                    map.put("catPlate",carids.get(i));
                    map.put("workNum",managementList.size());
                    map.put("purchase",purchase);
                    map.put("erp_repair",erp_repair);
                    map.put("maintian",maintian);
                    map.put("allAmount",purchase+erp_repair+maintian);
                    mapList.add(map);
                }

            }
            Map<String,Object> map=new HashMap<String, Object>();
            map.put("allpurchase",allpurchase);
            map.put("allerp_repair",allerp_repair);
            map.put("allmaintian",allmaintian);
            map.put("allmoney",allmoney);
            map.put("wokeNum",wokeNum);
            objectList.add(map);
            objectList.add(mapList);
            result.setCount(1);
            result.setData(objectList);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }


    @RequestMapping("/getMansgementByCarPlate")
    @ApiOperation("查询车辆一段时间内的工作单")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "carPlate", value = "车辆牌号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<List<ErpManagement>> getMansgementByCarPlate(Integer custId,String startDate,String endDate,String carPlate) {
        Result<List<ErpManagement>>  result=new Result<List<ErpManagement>>();
        try{
            result.setCount(1);
            result.setData(managementService.selectList(new EntityWrapper<ErpManagement>().eq("car_number",carPlate).and().ge("dt",startDate).and().le("dt",endDate)));
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    ///////////////////通用/////////////////////////////
    @RequestMapping("/gojianceweihu")
    @ApiOperation("检测维护")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<List<ErpCustomer>> getjianceweihu(Integer custId) {
        Result<List<ErpCustomer>>  result=new Result<List<ErpCustomer>>();
        try{

            ErpCustomer customer=customerService.selectById(custId);
            customer.setNumber(customer.getNumber()+1);
            customerService.updateById(customer);
            List<ErpCustomer> customers=customerService.selectList(new EntityWrapper<ErpCustomer>().eq("cus_sup_company",customer.getCusCode()).or().eq("cus_service_com",customer.getCusCode()).orderBy("number",true));
            customers.add(customer);

            result.setCount(1);
            result.setData(customers);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    ///////////////////通用/////////////////////////////
    @RequestMapping("/gojianceweihuCar")
    @ApiOperation("检测维护查询车辆")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> gojianceweihuCar(Integer custId) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> map=new HashMap<String,Object>();
//            List<ErpCustomerCar> customerCars=carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("customer_id",custId).and().isNull("car_drive"));
//            List<ErpCustomerCar> customerCarList=carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("customer_id",custId).and().isNotNull("car_drive"));
            List<ErpCustomerCar> erpCustomerCars = carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("car_type2", "挂车").eq("customer_id",custId));
            List<ErpCustomerCar> erpCustomerCars1 = carService.selectList(new EntityWrapper<ErpCustomerCar>().notIn("car_type2", "挂车").eq("customer_id",custId));
            map.put("putongche",erpCustomerCars1);
            map.put("guache",erpCustomerCars);
//            map.put("dagua",customerCars);
//            map.put("kacha",customerCarList);
            result.setCount(1);
            result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }


    @RequestMapping("/getcustomerCarByCode")///////////////////通用/////////////////////////////
    @ApiOperation("检测维护根据车牌号编码名称模糊查询车辆")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "custId", value = "登陆的客户ID", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "code", value = "查询字段", required = false, dataType = "String", paramType = "query")
    })
    public @ResponseBody
    Result<List<Map<String,Object>>> getcustomerCarByCode(String code,Integer custId) {
        Result<List<Map<String,Object>>>  result=new Result<List<Map<String,Object>>>();
        try{
            List<Map<String,Object>> mapList=new ArrayList<Map<String, Object>>();
            List<ErpCustomer> customer=customerService.selectList(new EntityWrapper<ErpCustomer>().like("cus_code",code).or().like("cus_name",code));
            if(0==customer.size()){
                Map<String,Object> map=new HashMap<String, Object>();
                ErpCustomer customer1=customerService.selectById(custId);
                List<ErpCustomer> customers=customerService.selectList(new EntityWrapper<ErpCustomer>().eq("cus_sup_company",customer1.getCusCode()).or().eq("cus_service_com",customer1.getCusCode()));
                customers.add(customer1);
                List<Integer> custIds=customers.stream().map(ErpCustomer::getId).collect(Collectors.toList());
                String custIdsStr=BlankUtil.listToString(custIds);
                List<ErpCustomerCar> customerCar=carService.selectList(new EntityWrapper<ErpCustomerCar>().like("car_plate",code).and().in("customer_id",custIdsStr));
                for (ErpCustomerCar car:customerCar) {
                    map.put("car",car);
                    map.put("customer",customerService.selectById(car.getCustomerId()));
                    mapList.add(map);
                }
            }else{
                Map<String,Object> map=new HashMap<String, Object>();
                List<Integer> custIds=customer.stream().map(ErpCustomer::getId).collect(Collectors.toList());
                String custIdsStr=BlankUtil.listToString(custIds);
                List<ErpCustomerCar> customerCar=carService.selectList(new EntityWrapper<ErpCustomerCar>().in("customer_id",custIdsStr));
                for (ErpCustomerCar car:customerCar) {
                    map.put("car",car);
                    map.put("customer",customerService.selectById(car.getCustomerId()));
                    mapList.add(map);
                }
            }
            result.setCount(1);
            result.setData(mapList);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/getManDetailsBycustId")
    @ApiOperation("工作汇总-客户查看工作单-查看工作单详情信息（统计管理中也可以用到）")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "sheetId", value = "工作单号", required = false, dataType = "String", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> getManDetailsBycustId(String sheetId) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            String sheet=sheetId.substring(0,4);
            Map<String,Object> map=new HashMap<String,Object>();
            if("XSWX".equals(sheet)){//销售维修
                 ErpSaleRepairOrder repairOrder=repairOrderService.selectOne(new EntityWrapper<ErpSaleRepairOrder>().eq("sale_repair_sheet_id",sheetId));
                List<ErpSaleRepairOrder> list= new ArrayList<>();
                list.add(repairOrder);
                 List<ErpSaleRepairRepair> saleRepairRepairs=saleRepairRepairService.selectList(new EntityWrapper<ErpSaleRepairRepair>().eq("order_id",repairOrder.getSaleRepairSheetId()));
                List<ErpSaleRepairGarage> saleRepairGarages=saleRepairGarageService.selectList(new EntityWrapper<ErpSaleRepairGarage>().eq("order_id",repairOrder.getSaleRepairSheetId()));
                List<ErpSaleRepairSale> saleRepairSales=repairSaleService.selectList(new EntityWrapper<ErpSaleRepairSale>().eq("order_id",repairOrder.getSaleRepairSheetId()));
                for (int i = 0; i < saleRepairSales.size(); i++) {

                    ErpSaleRepairSale erpSaleRepairSale =  saleRepairSales.get(i);
                    ErpCustomerWarehouse erpCustomerWarehouse = erpCustomerWarehouseService.selectById(erpSaleRepairSale.getWarehouseId());

                    erpSaleRepairSale.setWarehouseName(erpCustomerWarehouse.getWarName());
                }
                map.put("saleRepairRepairs",saleRepairRepairs);
                map.put("saleRepairGarages",saleRepairGarages);
                map.put("saleRepairSales",saleRepairSales);
                map.put("saleRepairOrder",list);
            }

            ErpManagement management=managementService.selectOne(new EntityWrapper<ErpManagement>().eq("work_id",sheetId));
            map.put("management",management);

            if("JCWH".equals(sheet)){//检测维护

                List<ErpTireArchivesWork> tireArchivesWorks=archivesWorkService.selectList(new EntityWrapper<ErpTireArchivesWork>().eq("work_sheet_id",sheetId));
                ErpInspectionOrder inspectionOrder=inspectionOrderService.selectOne(new EntityWrapper<ErpInspectionOrder>().eq("form_id",sheetId));
                List<ErpInspectionOrder> list= new ArrayList<>();
                list.add(inspectionOrder);
                List<ErpInspectionContent> inspectionContents=inspectionContentService.selectList(new EntityWrapper<ErpInspectionContent>().eq("form_id",sheetId));
                map.put("tireArchivesWorks",tireArchivesWorks);
                map.put("inspectionOrder",list);
                map.put("inspectionContents",inspectionContents);
            }
            if("WLLZ".equals(sheet)){//被动出库//物料流转
                ErpMaterielFlow flow=flowService.selectOne(new EntityWrapper<ErpMaterielFlow>().eq("materiel_flow_sheet_id",sheetId));
                List<ErpMaterielFlow> list= new ArrayList<>();
                list.add(flow);
                List<ErpMaterielFlowSummary> summary=flowSummaryService.selectList(new EntityWrapper<ErpMaterielFlowSummary>().eq("work_sheet_id",sheetId));
                for (ErpMaterielFlowSummary flowSummary:summary) {
                    flowSummary.setFlowMateriel(flowMaterielService.selectById(flowSummary.getMaterielId()));
                }
                map.put("flow",list);
                map.put("summary",summary);
            }
            if(sheet.equals("ZLLP")||sheet.equals("WLSP")) {
            	ErpClaims ec=claimsService.selectOne(new EntityWrapper<ErpClaims>().eq("claims_id", sheetId));
            	map.put("ErpClaims",ec);
            }
            result.setCount(1);
              result.setData(map);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }



    @RequestMapping("/getManagements")
    @ApiOperation("工作汇总")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户ID", required = false, dataType = "String", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> getManagements(Integer custId,@RequestParam(value="startDate",defaultValue="")String startDate,@RequestParam(value="endDate",defaultValue="")String endDate) {
        Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> mapall=new HashMap<>();
            ErpCustomer customer=customerService.selectById(custId);
            List<ErpCustomer> customers=customerService.selectList(new EntityWrapper<ErpCustomer>().eq("cus_sup_company",customer.getCusCode()).or().eq("cus_service_com",customer.getCusCode()).orderBy("id", true));
            customers.add(customer);
            /*List<String> custIds=customers.stream().map(ErpCustomer::getCusName).collect(Collectors.toList());
            String custIdsStr= BlankUtil.listString(custIds);
             Map<String,Object> topMap=new HashMap<String,Object>();
            Integer allNum=managementService.selectCount(new EntityWrapper<ErpManagement>().in("work_place",custIdsStr).and().ge("dt",startDate).and().le("dt",endDate));//查询所有的有关的工作单数量
            List<ErpManagement> managements=managementService.selectList(new EntityWrapper<ErpManagement>().ge("dt",startDate).and().le("dt",endDate).and().in("work_place",custIdsStr));//查询所有的有关的工作单
            List<Integer> custids=managements.stream().distinct().map(ErpManagement::getCustomerId).collect(Collectors.toList());
            //List<ErpManagement> managementCars=managementService.selectList(new EntityWrapper<ErpManagement>().isNotNull("car_number").and().in("customer_id",custIdsStr).and().ge("dt",startDate).and().le("dt",endDate));//查询所有的有关的车辆信息不为空工作单
            List<String> custCarIds=managements.stream().distinct().map(ErpManagement::getCarNumber).collect(Collectors.toList());
            Double allPurchase=managements.stream().mapToDouble(ErpManagement::getPurchase).sum();
            Double allSail=managements.stream().mapToDouble(ErpManagement::getSail).sum();
            Double allRepair=managements.stream().mapToDouble(ErpManagement::getErpRepair).sum();
            Double allMaintian=managements.stream().mapToDouble(ErpManagement::getMaintian).sum();
            Double allCash=managements.stream().mapToDouble(ErpManagement::getCash).sum();
            Double allAccounts=managements.stream().mapToDouble(ErpManagement::getAccounts).sum();
            Double allCope=managements.stream().mapToDouble(ErpManagement::getCope).sum();


            topMap.put("allNum",allNum);//工作单总数
            topMap.put("allcustomerNum",custids.size());//客户总数
            topMap.put("allCarNum",custCarIds.size());//车辆总数
            topMap.put("allPurchase",allPurchase);//采购总数
            topMap.put("allSail",allSail);//销售总数
            topMap.put("allRepair",allRepair);//维修总数
            topMap.put("allMaintian",allMaintian);//维护总数
            topMap.put("allCash",allCash);//现款总数
            topMap.put("allAccounts",allAccounts);//应收总数
            topMap.put("allCope",allCope);//应付总数*/
            Map<String, Object> topMap=managementService.selectTong(startDate, endDate);
            mapall.put("topMap",topMap);

            List<Map<String,Object>> mapList=new ArrayList<>();
            for (ErpCustomer customer1:customers) {
                Map<String,Object> map=new HashMap<>();
                map=managementService.selectByWorkPlace(customer1.getCusName(), startDate, endDate);
                map.put("cusName", customer1.getCusName());

                mapList.add(map);
                if(customer1.getId()==customer.getId()){
                    Collections.swap(mapList,0,mapList.size()-1);
                }
                /*Integer custallNum=managementService.selectCount(new EntityWrapper<ErpManagement>().eq("work_place",customer1.getCusName()).and().ge("dt",startDate).and().le("dt",endDate));//查询客户所有的有关的工作单数量
                List<ErpManagement> custmanagements=managementService.selectList(new EntityWrapper<ErpManagement>().ge("dt",startDate).and().le("dt",endDate).and().in("customer_id",custIdsStr));//查询客户所有的有关的工作单
                List<ErpManagement> custmanagementCars=managementService.selectList(new EntityWrapper<ErpManagement>().isNotNull("car_number").and().in("customer_id",custIdsStr).and().ge("dt",startDate).and().le("dt",endDate));//查询所有的有关的车辆信息不为空工作单
                List<String> custcustCarIds=custmanagementCars.stream().distinct().map(ErpManagement::getCarNumber).collect(Collectors.toList());
                Double custallPurchase=custmanagements.stream().mapToDouble(ErpManagement::getPurchase).sum();
                Double custallSail=custmanagements.stream().mapToDouble(ErpManagement::getSail).sum();
                Double custallRepair=custmanagements.stream().mapToDouble(ErpManagement::getErpRepair).sum();
                Double custallMaintian=custmanagements.stream().mapToDouble(ErpManagement::getMaintian).sum();
                Double custallCash=custmanagements.stream().mapToDouble(ErpManagement::getCash).sum();
                Double custallAccounts=custmanagements.stream().mapToDouble(ErpManagement::getAccounts).sum();
                Double custallCope=custmanagements.stream().mapToDouble(ErpManagement::getCope).sum();
                map.put("custallNum",custallNum);//工作单数
                map.put("custallcustomerNum",0);//客数
                map.put("customer",customer1);//客户信息
                map.put("custallCarNum",custcustCarIds.size());//车辆数
                map.put("custallPurchase",custallPurchase);//采购数
                map.put("custallSail",custallSail);//销售数
                map.put("custallRepair",custallRepair);//维修数
                map.put("custallMaintian",custallMaintian);//维护数
                map.put("custallCash",custallCash);//现款数
                map.put("custallAccounts",custallAccounts);//应收数
                map.put("custallCope",custallCope);//应付数
*/
            }
            mapall.put("mapList",mapList);
            result.setCount(1);
            result.setData(mapall);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }





    @RequestMapping("/getManagementsBycustId")
    @ApiOperation("工作汇总-客户查看工作单")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "custName", value = "客户公司名", required = false, dataType = "String", paramType = "query")
    })
    public @ResponseBody
    Result<Map<String,Object>> getManagementsBycustId(String custName,@RequestParam(value="startDate",defaultValue="")String startDate,@RequestParam(value="endDate",defaultValue="")String endDate) {
    	/* Result<Map<String,Object>>  result=new Result<Map<String,Object>>();
        try{
            Map<String,Object> mapall=new HashMap<>();
            ErpCustomer customer=customerService.selectById(custId);
            Map<String,Object> topMap=new HashMap<String,Object>();
            Integer allNum=managementService.selectCount(new EntityWrapper<ErpManagement>().eq("customer_id",customer.getId()).and().ge("dt",startDate).and().le("dt",endDate));//查询所有的有关的工作单数量
            List<ErpManagement> managements=managementService.selectList(new EntityWrapper<ErpManagement>().ge("dt",startDate).and().le("dt",endDate).and().eq("customer_id",customer.getId()));//查询所有的有关的工作单
            List<Integer> custids=managements.stream().distinct().map(ErpManagement::getCustomerId).collect(Collectors.toList());
            List<ErpManagement> managementCars=managementService.selectList(new EntityWrapper<ErpManagement>().isNotNull("car_number").and().eq("customer_id",customer.getId()).and().ge("dt",startDate).and().le("dt",endDate));//查询所有的有关的车辆信息不为空工作单
            List<String> custCarIds=managements.stream().distinct().map(ErpManagement::getCarNumber).collect(Collectors.toList());
            Double allPurchase=managements.stream().mapToDouble(ErpManagement::getPurchase).sum();
            Double allSail=managements.stream().mapToDouble(ErpManagement::getSail).sum();
            Double allRepair=managements.stream().mapToDouble(ErpManagement::getErpRepair).sum();
            Double allMaintian=managements.stream().mapToDouble(ErpManagement::getMaintian).sum();
            Double allCash=managements.stream().mapToDouble(ErpManagement::getCash).sum();
            Double allAccounts=managements.stream().mapToDouble(ErpManagement::getAccounts).sum();
            Double allCope=managements.stream().mapToDouble(ErpManagement::getCope).sum();


            topMap.put("allNum",allNum);//工作单数
            topMap.put("allcustomerNum",custids.size());//客户数
            topMap.put("allCarNum",custCarIds.size());//车辆数
            topMap.put("allPurchase",allPurchase);//采购数
            topMap.put("allSail",allSail);//销售数
            topMap.put("allRepair",allRepair);//维修数
            topMap.put("allMaintian",allMaintian);//维护数
            topMap.put("allCash",allCash);//现款数
            topMap.put("allAccounts",allAccounts);//应收数
            topMap.put("allCope",allCope);//应付数
            mapall.put("topMap",topMap);
            mapall.put("managements",managements);
            
            result.setCount(1);
            result.setData(mapall);
        }catch (Exception e){e.printStackTrace();}*/
        return managementService.selectByWorkPlaceList(custName, startDate, endDate);
    }

    //根据单号修改处理状态
    @RequestMapping("/editType")
    public Result<Boolean> editType(String sheelId){
    	ErpManagement ment=managementService.selectOne(new EntityWrapper<ErpManagement>().eq("work_id", sheelId));
    	if(ment!=null) {
			ment.setType(1);
			Boolean pan=managementService.updateById(ment);
			return new Result<Boolean>(pan, 1);
    	}else {
    		return new Result<Boolean>(false, 1);
    	}
    }
}

